/*
This code will provide the coefficients for eTable 2: Payment Sensitivity Analysis
Effect estimate for column 4 can be found in the lincom command
*/

log using "$logs\eTable2.txt", replace text name(etable2)

use "$data_deri\payment_panel", clear


*Panel A: sensitivity analyses, weighted by Medicare Advantage enrollment
*Column 1 - see coefficient for post#q4_prop_flag1#Top 25% Proportional Cuts
xtreg tot_payment_ra ib2011.year phaseIn##q4_prop_flag post##q4_prop_flag [aweight = imp_enrl], fe vce(robust)
outreg2 using "$output\eTable2", excel replace label nocons stats(coef ci) ctitle(Quartile cuts) keep(1.post#1.q4_prop_flag)

*Column 2 - see coefficient for post#med_prop_flag1#Top 50% Proportional Cuts
xtreg tot_payment_ra ib2011.year phaseIn##med_prop_flag post##med_prop_flag [aweight = imp_enrl], fe vce(robust)
outreg2 using "$output\eTable2", excel append label nocons stats(coef ci) ctitle(Median Cuts) keep(1.post#1.med_prop_flag)

*Column 3 - see coefficient for post#q10_prop_flag1#Top 10% Proportional Cuts
xtreg tot_payment_ra ib2011.year phaseIn##q10_prop_flag post##q10_prop_flag [aweight = imp_enrl], fe vce(robust)
outreg2 using "$output\eTable2", excel append label nocons stats(coef ci) ctitle(Decile Cuts) keep(1.post#1.q10_prop_flag)

*Column 4 - see coefficients for pre_trend and lincom command
xtreg tot_payment_ra ib2011.year q4_yr* q4_prop_flag pre_trend [aweight = imp_enrl], fe vce(robust)
lincom (q4_yr17+q4_yr18+q4_yr19)/3
outreg2 using "$output\eTable2", excel append label nocons stats(coef ci) ctitle(Parallel Trends Test) keep(pre_trend)

*Column 5 - see coefficient for post#c.bnch_cut_prop1
xtreg tot_payment_ra ib2011.year phaseIn##c.bnch_cut_prop post##c.bnch_cut_prop [aweight = imp_enrl], fe vce(robust)
outreg2 using "$output\eTable2", excel append label nocons stats(coef ci) ctitle(Continuous Benchmark) keep(1.post#c.bnch_cut_prop)


*Panel B: sensitivity analyses, unweighted
*Column 1 - see coefficient for post#q4_prop_flag1#Top 25% Proportional Cuts
xtreg tot_payment_ra ib2011.year phaseIn##q4_prop_flag post##q4_prop_flag, fe vce(robust)
outreg2 using "$output\eTable2", excel append label nocons stats(coef ci) ctitle(Quartile cuts) keep(1.post#1.q4_prop_flag)

*Column 2 - see coefficient for post#med_prop_flag1#Top 50% Proportional Cuts
xtreg tot_payment_ra ib2011.year phaseIn##med_prop_flag post##med_prop_flag, fe vce(robust)
outreg2 using "$output\eTable2", excel append label nocons stats(coef ci) ctitle(Median Cuts) keep(1.post#1.med_prop_flag)

*Column 3 - see coefficient for post#q10_prop_flag1#Top 10% Proportional Cuts
xtreg tot_payment_ra ib2011.year phaseIn##q10_prop_flag post##q10_prop_flag, fe vce(robust)
outreg2 using "$output\eTable2", excel append label nocons stats(coef ci) ctitle(Decile Cuts) keep(1.post#1.q10_prop_flag)

*Column 4 - see coefficients for pre_trend and lincom command
xtreg tot_payment_ra ib2011.year q4_yr* q4_prop_flag pre_trend, fe vce(robust)
lincom (q4_yr17+q4_yr18+q4_yr19)/3
outreg2 using "$output\eTable2", excel append label nocons stats(coef ci) ctitle(Parallel Trends Test) keep(pre_trend)

*Column 5 - see coefficient for post#c.bnch_cut_prop1
xtreg tot_payment_ra ib2011.year phaseIn##c.bnch_cut_prop post##c.bnch_cut_prop, fe vce(robust)
outreg2 using "$output\eTable2", excel append label nocons stats(coef ci) ctitle(Continuous Benchmark) keep(1.post#c.bnch_cut_prop)

log close etable2
